﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;

namespace NK.Mvc3.Models
{
    public class Sale
    {
        public int ID { get; set; }

        public DateTime DateSale { get; set; }

        public string StaffName { get; set; }

        public virtual ICollection<SaleDetail> SaleDetails { get; set; } 

        [DisplayFormat(DataFormatString = "{0:#,###}")]
        public double Total
        {
            get
            {
                return SaleDetails.Sum(detail => detail.TotalCost);
            }
        }
    }
}